package tianrun.ziguan.api.calculate.config.controller.rollback;

import io.swagger.annotations.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tianrun.ziguan.api.calculate.config.dto.request.RollbackByAssetParam;
import tianrun.ziguan.api.calculate.config.service.rollback.IRollbackService;
import tianrun.ziguan.api.calculate.config.utils.HttpResponseTools;
import tianrun.ziguan.api.common.core.base.ResultBody;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("rollback")
@Api(tags = "回退")
public class RollbackController {

    private  final IRollbackService rollbackService;

    public RollbackController(IRollbackService rollbackService) {
        this.rollbackService = rollbackService;
    }
    @ApiOperation(value = "根据设备点位回退")
    @ApiResponses({@ApiResponse(code = 200, message = "ok")})
    @PostMapping("byAsset")
    public ResponseEntity<ResultBody> byAsset(@RequestBody @Valid RollbackByAssetParam param){
        return HttpResponseTools.good(ResultBody.of(rollbackService.rollbackByAsset(param)));
    }
}
